<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/prettyphoto.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.mselect.js?"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.prettyphoto.js"></script>
<script type="text/javascript">
$(function(){
	$("a[rel^='pretty_photo']").prettyPhoto({theme:'facebook'});
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
	$(".warehouse_notes_icon").colorbox({width:"50%", height:"50%", iframe:true});
	$("#customize_display").dialog({autoOpen:false,modal:true, height: 600, width: 450});
	var purchase_categories_data = <?=$purchase_categories?>;
	$(document).mselect(purchase_categories_data, 'product_categories_id','product_categories_id', "<?=isset($_GET['product_categories_id'])?$_GET['product_categories_id']:0?>");
	$(".customize_click").click(function(){
		$("#customize_display").dialog("open");
	});
	$(".self_status").mouseover(function(){
		$(this).next().show();
	}).mouseout(function(){
		$(this).next().hide();
	});
	$(".more_status").mouseover(function(){
		$(this).show();
	}).mouseout(function(){
		$(this).hide();
	});
	$("#request_download").click(function(){
		var current_tag = $(this);
		$(this).attr("disabled", true);
		var url_arr_json = current_tag.prev().val();
		$.ajax({
			url: "<?=url('DataCenter::Sales/StockAnalysisDownload')?>&url_arr_json=" + url_arr_json,
			type: "get",
			dataType: "json",
			beforeSend:
				function()
				{
					$("#download_loading_img").html("<img src='<?=Q::ini('custom_system/base_url')?>img/loading.gif' />");
				},
			error:
				function()
				{
					$("#download_loading_img").html("系统异常，导出失败！");
				},
			success:
				function(ret)
				{
					$("#download_loading_img").html("");
					if (ret['ack'] == 'success')
					{
						current_tag.parent().append("<a href='"+ret['url']+"'>下载文件</a>");
					}
					else
					{
						current_tag.parent().append("请求失败");
					}
				}
		})
	});
	$("#refresh_status").click(function(){
		$("#refresh_status").attr("disabled", true);
		$.ajax({
			url: "<?=url('DataCenter::Sales/UpdateProductSalesStatusAllArtificial')?>",
			type: "get",
			dateType: "json",
			beforeSend:
				function(){
					$("#loading_img").html("<img src='<?=Q::ini('custom_system/base_url')?>img/loading.gif' />");
				},
			success:
				function()
				{
					$("#loading_img").html("");
				}
		});
	});
	$(".change_sales_status_click").click(function(){
		var current_tag = $(this);
		var data = current_tag.next().val();
		$.ajax({
			url: "<?=url('DataCenter::Sales/UpdateProductSalesStatusSingle')?>&data=" + data,
			type: "get",
			dataType: "json",
			success:
				function(ret)
				{
					if (ret['ack'] == 'success')
					{
						current_tag.parent().parent().prev().html(ret['status_html']);
					}
					else
					{
						alert("修改失败");
					}
				}
		});
	});
	$("ul.dropfalse").sortable({
		connectWith: "ul",
		dropOnEmpty: false
	});
	$("#sortable1 input[type='checkbox']").change(function(){
		var text = $(this).parent().text();
		var value = $(this).val();
		if ($(this).is(":checked"))
		{
			$("#sortable2").append('<li class="ui-state-highlight">'+text+'<input type="hidden" name="fieldname['+value+']" value="'+text+'" /></li>');
		}
		else
		{
			$("#sortable2 li").each(function(){
				if ($(this).text() === text)
				{
					$(this).remove();
				}
			});
		}
	});
	$(function(){
		var tableH = $("#list").find("thead tr").offset().top;
		var tableW = $("#list").width();
		var $curOrgTr = $("#list").clone(true);
		$(window).scroll(function(){
			var scroH = $(this).scrollTop();
			if (tableH - scroH <= 100)
			{
				$curOrgTr.find("tbody").remove();
				$curOrgTr.find("thead th").each(function(i){
					$(this).css("width", $("#list").find("th:eq(" + i + ")").width());
				});
				$curOrgTr.appendTo("#table_thead");
				$("#table_thead").css("width", tableW+1+"px");
			}
			else
			{
				$("#table_thead").html('');
			}
		});
	});
})
</script>
<style type="text/css">
.more_status {
	position: absolute;
	top: 16px;
	left: 2px;
	width: 55px;
	background-color: #eeeeee;
	z-index: 100;
	display: none;
	border: 1px solid;
}
.change_status_click:hover{cursor: pointer;}
#sortable1, #sortable2 {list-style-type: none; margin: 0; padding: 0; float: left; margin-right: 50px; background: #eee; padding: 5px; width: 100px; height: auto;}
ul .ui-state-highlight {margin: 3px; padding: 3px; font-size: 1em; font-color: orange; width: 85px; }
#sortable1 li {font-size: 15px; padding: 4px 0;}
#sortable1 li label, #sortable2 li {cursor: pointer;}
</style>
<fieldset><legend>查询条件</legend>
<form method="get">
<? include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>产品生成时间</th>
	<td>
		<input type="text" name="begin_create_time" class="datepicker" value="<?=isset($_GET['begin_create_time']) ? $_GET['begin_create_time'] : ''?>" /> to 
		<input type="text" name="end_create_time" class="datepicker" value="<?=isset($_GET['end_create_time']) ? $_GET['end_create_time'] : ''?>" />
	</td>
</tr>
<tr>
	<th>备注时间</th>
	<td>
		<input type="text" name="begin_note_time" class="datepicker" value="<?=isset($_GET['begin_note_time']) ? $_GET['begin_note_time'] : ''?>" /> to 
		<input type="text" name="end_note_time" class="datepicker" value="<?=isset($_GET['end_note_time']) ? $_GET['end_note_time'] : ''?>" />
	</td>
</tr>
<tr>
	<th>出图时间</th>
	<td>
		<input type="text" name="begin_img_add_time" class="datepicker" value="<?=isset($_GET['begin_img_add_time']) ? $_GET['begin_img_add_time'] : ''?>" /> to 
		<input type="text" name="end_img_add_time" class="datepicker" value="<?=isset($_GET['end_img_add_time']) ? $_GET['end_img_add_time'] : ''?>" />
	</td>
</tr>
<tr>
	<th>产品编号</th>
	<td colspan="3">
		<input name="product_number" value="<?=isset($_GET['product_number']) ? $_GET['product_number'] : ''?>" size="70" />
	</td>
</tr>
<tr>
	<th></th>
	<td>说明：多个产品编号用英文逗号,分开</td>
</tr>
<tr>
	<th>产品关键字</th>
	<td colspan="3"><input type="text" name="product_name" value="<?=isset($_GET['product_name']) ? $_GET['product_name'] : ''?>" /></td>
</tr>
<tr>
	<th>备注关键字</th>
	<td colspan="3"><input type="text" name="purchase_note" value="<?=isset($_GET['purchase_note']) ? $_GET['purchase_note'] : ''?>" /></td>
</tr>
<tr>
	<th>产品类别</th>
	<td colspan="3"><input type="hidden" name="product_categories_id" id="product_categories_id" /></td>
</tr>
<tr>
	<th>仓库</th>
	<td>
		<select name="warehouse_id">
		<?foreach ($warehouse as $w):?>
		<option value="<?=$w['id']?>" <?if (isset($_GET['warehouse_id']) && $_GET['warehouse_id'] == $w['id'])echo "selected='selected'"?>><?=$w['name']?></option>
		<?endforeach;?>
		</select>
	</td>
	<th>备注人</th>
	<td>
		<select name="purchase_note_user_id">
		<option></option>
		<?foreach ($user as $u):?>
		<option value="<?=$u['id']?>" <?if (isset($_GET['purchase_note_user_id']) && $u['id'] == $_GET['purchase_note_user_id'])echo "selected='selected'"?>><?=$u['name']?></option>
		<?endforeach;?>				
		</select>
	</td>
</tr>
<tr>
	<th>可用库存</th>
	<td>
		<select name="available_quantity_operator">
			<option value="">请选择..</option>
			<option value="=" <?if (isset($_GET['available_quantity_operator']) && $_GET['available_quantity_operator'] == '=')echo "selected='selected'"?>>=</option>
			<option value=">=" <?if (isset($_GET['available_quantity_operator']) && $_GET['available_quantity_operator'] == '>=')echo "selected='selected'"?>>>=</option>
			<option value="<=" <?if (isset($_GET['available_quantity_operator']) && $_GET['available_quantity_operator'] == '<=')echo "selected='selected'"?>><=</option>
		</select>
		<input type="text" name="available_quantity" value="<?=isset($_GET['available_quantity']) ? $_GET['available_quantity'] : ''?>" />
	</td>
	<th>实际库存</th>
	<td>
		<select name="actual_quantity_operator">
			<option value="">请选择..</option>
			<option value="=" <?if (isset($_GET['actual_quantity_operator']) && $_GET['actual_quantity_operator'] == '=')echo "selected='selected'"?>>=</option>
			<option value=">=" <?if (isset($_GET['actual_quantity_operator']) && $_GET['actual_quantity_operator'] == '>=')echo "selected='selected'"?>>>=</option>
			<option value="<=" <?if (isset($_GET['actual_quantity_operator']) && $_GET['actual_quantity_operator'] == '<=')echo "selected='selected'"?>><=</option>
		</select>
		<input type="text" name="actual_quantity" value="<?=isset($_GET['actual_quantity']) ? $_GET['actual_quantity'] : ''?>" />
	</td>
</tr>
<tr>
	<th>周销</th>
	<td>
		<select name="weekly_sales_operator">
			<option value="">请选择..</option>
			<option value="=" <?if (isset($_GET['weekly_sales_operator']) && $_GET['weekly_sales_operator'] == '=')echo "selected='selected'"?>>=</option>
			<option value=">=" <?if (isset($_GET['weekly_sales_operator']) && $_GET['weekly_sales_operator'] == '>=')echo "selected='selected'"?>>>=</option>
			<option value="<=" <?if (isset($_GET['weekly_sales_operator']) && $_GET['weekly_sales_operator'] == '<=')echo "selected='selected'"?>><=</option>
		</select>
		<input type="text" name="weekly_sales" value="<?=isset($_GET['weekly_sales']) ? $_GET['weekly_sales'] : ''?>" />
	</td>
	<th>月销</th>
	<td>
		<select name="monthly_sales_operator">
			<option value="">请选择..</option>
			<option value="=" <?if (isset($_GET['monthly_sales_operator']) && $_GET['monthly_sales_operator'] == '=')echo "selected='selected'"?>>=</option>
			<option value=">=" <?if (isset($_GET['monthly_sales_operator']) && $_GET['monthly_sales_operator'] == '>=')echo "selected='selected'"?>>>=</option>
			<option value="<=" <?if (isset($_GET['monthly_sales_operator']) && $_GET['monthly_sales_operator'] == '<=')echo "selected='selected'"?>><=</option>
		</select>
		<input type="text" name="monthly_sales" value="<?=isset($_GET['monthly_sales']) ? $_GET['monthly_sales'] : ''?>" />
	</td>
</tr>
<tr>
	<th>均销</th>
	<td>
		<select name="average_sales_operator">
			<option value="">请选择..</option>
			<option value="=" <?if (isset($_GET['average_sales_operator']) && $_GET['average_sales_operator'] == '=')echo "selected='selected'"?>>=</option>
			<option value=">=" <?if (isset($_GET['average_sales_operator']) && $_GET['average_sales_operator'] == '>=')echo "selected='selected'"?>>>=</option>
			<option value="<=" <?if (isset($_GET['average_sales_operator']) && $_GET['average_sales_operator'] == '<=')echo "selected='selected'"?>><=</option>
		</select>
		<input type="text" name="average_sales" value="<?=isset($_GET['average_sales']) ? $_GET['average_sales'] : ''?>" />
	</td>
	<th>已缺货期</th>
	<td>
		<select name="oos_days_operator">
			<option value="">请选择..</option>
			<option value="=" <?if (isset($_GET['oos_days_operator']) && $_GET['oos_days_operator'] == '=')echo "selected='selected'"?>>=</option>
			<option value=">=" <?if (isset($_GET['oos_days_operator']) && $_GET['oos_days_operator'] == '>=')echo "selected='selected'"?>>>=</option>
			<option value="<=" <?if (isset($_GET['oos_days_operator']) && $_GET['oos_days_operator'] == '<=')echo "selected='selected'"?>><=</option>
		</select>
		<input type="text" name="oos_days" value="<?=isset($_GET['oos_days']) ? $_GET['oos_days'] : ''?>" />
	</td>
</tr>
<tr>
	<th>录单数</th>
	<td>
		<select name="purchase_budget_operator">
			<option value="">请选择..</option>
			<option value="=" <?if (isset($_GET['purchase_budget_operator']) && $_GET['purchase_budget_operator'] == '=')echo "selected='selected'"?>>=</option>
			<option value=">=" <?if (isset($_GET['purchase_budget_operator']) && $_GET['purchase_budget_operator'] == '>=')echo "selected='selected'"?>>>=</option>
			<option value="<=" <?if (isset($_GET['purchase_budget_operator']) && $_GET['purchase_budget_operator'] == '<=')echo "selected='selected'"?>><=</option>
		</select>
		<input type="text" name="purchase_budget" value="<?=isset($_GET['purchase_budget']) ? $_GET['purchase_budget'] : ''?>" />
	</td>
	<th>采购数</th>
	<td>
		<select name="purchase_quantity_operator">
			<option value="">请选择..</option>
			<option value="=" <?if (isset($_GET['purchase_quantity_operator']) && $_GET['purchase_quantity_operator'] == '=')echo "selected='selected'"?>>=</option>
			<option value=">=" <?if (isset($_GET['purchase_quantity_operator']) && $_GET['purchase_quantity_operator'] == '>=')echo "selected='selected'"?>>>=</option>
			<option value="<=" <?if (isset($_GET['purchase_quantity_operator']) && $_GET['purchase_quantity_operator'] == '<=')echo "selected='selected'"?>><=</option>
		</select>
		<input type="text" name="purchase_quantity" value="<?=isset($_GET['purchase_quantity']) ? $_GET['purchase_quantity'] : ''?>" />
	</td>
</tr>
<tr>
	<th>筛选</th>
	<td>
	<label><input type="checkbox" name="oos" <?if (isset($_GET['oos']))echo "checked=checked";?>/> 缺货</label>
	<label><input type="checkbox" name="backorder" <?if (isset($_GET['backorder']))echo "checked=checked";?>/> 已欠货</label></td>
</tr>
<tr>
	<th>采购状态</th>
	<td colspan="3">
		<?foreach (Q::ini('custom_flag/product_purchase_status') as $ps):?>
		<label><input type="checkbox" name="purchase_status[<?=$ps['value']?>]" value="<?=$ps['value']?>" <?if (isset($_GET['purchase_status'][$ps['value']]) && $_GET['purchase_status'][$ps['value']] == $ps['value'])echo "checked=checked"?> /> <font color="#<?=$ps['color']?>"><?=$ps['name']?></font></label>
		<?endforeach;?>
	</td>
</tr>
<tr>
	<th>销售状态</th>
	<td colspan="3">
		<?foreach (Q::ini('custom_flag/product_sales_status') as $ss):?>
		<label><input type="checkbox" name="sales_status[<?=$ss['value']?>]" value="<?=$ss['value']?>" <?if (isset($_GET['sales_status'][$ss['value']]) && $_GET['sales_status'][$ss['value']] == $ss['value'])echo "checked=checked"?> /> <font color="#<?=$ss['color']?>"><?=$ss['name']?></font></label>
		<?endforeach;?>
	</td>
</tr>
<tr>
	<th>警告状态</th>
	<td colspan="3">
		<?foreach (Q::ini('custom_flag/product_warning_status') as $ws):?>
		<label><input type="checkbox" name="warning_status[<?=$ws['value']?>]" value="<?=$ws['value']?>" <?if (isset($_GET['warning_status'][$ws['value']]) && $_GET['warning_status'][$ws['value']] == $ws['value'])echo 'checked="checked"'?> /> <font color="#<?=$ws['color']?>"><?=$ws['name']?></font></label>
		<?endforeach;?>
	</td>
</tr>
<tr>
	<th>采购备注</th>
	<td colspan="3">
		<?foreach (Q::ini('custom_flag/product_basic_purchase_note_flag') as $pm):?>
		<label><input type="checkbox" name="purchase_note_flag[<?=$pm['value']?>]" value="<?=$pm['value']?>" <?if (isset($_GET['purchase_note_flag'][$pm['value']]) && $_GET['purchase_note_flag'][$pm['value']] == $pm['value'])echo 'checked="checked"'?> /> <?=$pm['name']?></label>
		<?endforeach;?>
	</td>
</tr>
<tr>
	<td></td>
	<td>
		<input type="hidden" name="is_search" value="1" />
		<input type="submit" class="button" value="查询" />
	</td>
	<td><input type="button" class="button" value="更新状态" id="refresh_status" /></td>
	<td><span id="loading_img"></span></td>
	<td>
		<?if (isset($url_arr_json)):?>
		<input type="hidden" value='<?=$url_arr_json?>' />
		<input type="button" class="button" value="请求下载" id="request_download" />
		<?endif;?>
	</td>
	<td><span id="download_loading_img"></span></td>
</tr>
</table>
</form>
</fieldset>
<?if (! empty($product)):?>
<a class="customize_click">自定义显示列</a>
<div id="table_thead" style="position: fixed; top: 50px; z-index: 100;"></div>
<table class="list_table" width="100%" id="list">
<thead>
<tr>
	<?foreach ($_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'] as $key => $th):?>
	<?if ($th == '产品编号'):?>
	<th width="70"><?=$th?></th>
	<?elseif ($th == '三个月均销'):?>
	<th width="70">
		<a href="<?=$url?>&sort_by=<?=$key?>&sort_order=<?=(isset($_GET['sort_by']) && ($_GET['sort_by'] == $key) && ($_GET['sort_order'] == 'desc')) ? 'asc' : 'desc'?>"><?=$th?></a>
		<?=(isset($_GET['sort_by']) && $_GET['sort_by'] == $key) ? ($_GET['sort_order'] == 'asc' ? '↑' : '↓') : ''?>
	</th>
	<?elseif ($th == '产品名称'):?>
	<th><?=$th?></th>
	<?elseif ($th == '已缺货期'):?>
	<th width="70">
		<a href="<?=$url?>&sort_by=<?=$key?>&sort_order=<?=(isset($_GET['sort_by']) && ($_GET['sort_by'] == $key) && ($_GET['sort_order'] == 'desc')) ? 'asc' : 'desc'?>"><?=$th?></a>
		<?=(isset($_GET['sort_by']) && $_GET['sort_by'] == $key) ? ($_GET['sort_order'] == 'asc' ? '↑' : '↓') : ''?>
	</th>
	<?elseif ($th == '最近采购价'):?>
	<th width="70">
		<a href="<?=$url?>&sort_by=product_basic.<?=$key?>&sort_order=<?=(isset($_GET['sort_by']) && ($_GET['sort_by'] == 'product_basic.' . $key) && ($_GET['sort_order'] == 'desc')) ? 'asc' : 'desc'?>"><?=$th?></a>
		<?=(isset($_GET['sort_by']) && $_GET['sort_by'] == 'product_basic.' . $key) ? ($_GET['sort_order'] == 'asc' ? '↑' : '↓') : ''?>
	</th>
	<?elseif ($th == '备注'):?>
	<th width="25"><?=$th?></th>
	<?elseif ($th == '周销' || $th == '月销'):?>
	<th width="40">
		<a href="<?=$url?>&sort_by=<?=$key?>&sort_order=<?=(isset($_GET['sort_by']) && ($_GET['sort_by'] == $key) && ($_GET['sort_order'] == 'desc')) ? 'asc' : 'desc'?>"><?=$th?></a>
		<?=(isset($_GET['sort_by']) && $_GET['sort_by'] == $key) ? ($_GET['sort_order'] == 'asc' ? '↑' : '↓') : ''?>
	</th>
	<?elseif ($th == '采购状态' || $th == '销售状态' || $th == '警告状态' || $th == '所在仓库' || $th == '最低售价' || $th == '采购备注'):?>
	<th width="60"><?=$th?></th>
	<?elseif ($th == '出图时间' || $th == '创建时间'):?>
	<th width="80"><?=$th?></th>
	<?elseif ($th == '重量g'):?>
	<th width="60">
		<a href="<?=$url?>&sort_by=product_basic.<?=$key?>&sort_order=<?=(isset($_GET['sort_by']) && ($_GET['sort_by'] == 'product_basic.' . $key) && ($_GET['sort_order'] == 'desc')) ? 'asc' : 'desc'?>"><?=$th?></a>
		<?=(isset($_GET['sort_by']) && $_GET['sort_by'] == 'product_basic.' . $key) ? ($_GET['sort_order'] == 'asc' ? '↑' : '↓') : ''?>
	</th>
	<?elseif ($th == '资料成本'):?>
	<th width="60">
		<a href="<?=$url?>&sort_by=product_basic.<?=$key?>&sort_order=<?=(isset($_GET['sort_by']) && ($_GET['sort_by'] == 'product_basic.' . $key) && ($_GET['sort_order'] == 'desc')) ? 'asc' : 'desc'?>"><?=$th?></a>
		<?=(isset($_GET['sort_by']) && $_GET['sort_by'] == 'product_basic.' . $key) ? ($_GET['sort_order'] == 'asc' ? '↑' : '↓') : ''?>
	</th>
	<?else:?>
	<th width="60">
		<a href="<?=$url?>&sort_by=<?=$key?>&sort_order=<?=(isset($_GET['sort_by']) && ($_GET['sort_by'] == $key) && ($_GET['sort_order'] == 'desc')) ? 'asc' : 'desc'?>"><?=$th?></a>
		<?=(isset($_GET['sort_by']) && $_GET['sort_by'] == $key) ? ($_GET['sort_order'] == 'asc' ? '↑' : '↓') : ''?>
	</th>
	<?endif;?>
	<?endforeach;?>
</tr>
</thead>
<tbody>
<?foreach ($product as $p):?>
<tr>
	<?foreach ($_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'] as $td):?>
		<?if ($td == '产品编号'):?>
		<td width="80">
			<?=$p['number']?>
			<?if ($p['pic_url']):?>
				<?$pretty_photo_number = 0;?>
				<?foreach ($p['pic_url'] as $pp):?>
				<a rel="pretty_photo[<?=$p['id']?>]" href="<?=$pp?>"><?if(!$pretty_photo_number):?><span class="img_icon"></span><?endif;?></a>
				<?$pretty_photo_number = 1;?>
				<?endforeach;?>
			<?endif;?>
			<?if ($p['sales_trend']):?>
				<span class="<?=Helper_BSS_Normal::getIniOne('product_sales_trend', 'value', $p['sales_trend'], 'icon_class') ?>"></span>
			<?endif;?>
		</td>
		<?elseif ($td == '产品名称'):?>
		<td align="left"><?=$p['product_basic_name']?></td>
		<?elseif ($td == '所在仓库'):?>
		<td><?=$p['warehouse_name']?></td>
		<?elseif ($td == '备注'):?>
		<td>
			<?if ($p['notes']):?>
			<a class="warehouse_notes_icon" title="产品备注" href="<?=url('DataCenter::Sales/ProductNotes', array('id' => $p['product_basic_id']));?>"></a>
			<?endif;?>
		</td>
		<?elseif ($td == '采购备注'):?>
		<td title="采购备注"><?=($p['purchase_note'])?></td>
		<?elseif ($td == '采购状态'):?>
		<td title="<?=empty($p['last_change_purchase_status_user_name']) ? '系统' : $p['last_change_purchase_status_user_name']?> <?=$p['last_change_purchase_status_time']?>"><span class="self_status" style="display: block;"><font color="#<?=Helper_BSS_Normal::getIniOne('product_purchase_status', 'value', $p['purchase_status'], 'color')?>"><?=Helper_BSS_Normal::getIniOne('product_purchase_status', 'value', $p['purchase_status'], 'name')?></font></span></td>
		<?elseif ($td == '销售状态'):?>
		<td title="<?=empty($p['last_change_sales_status_user_name']) ? '系统' : $p['last_change_sales_status_user_name']?> <?=$p['last_change_sales_status_time']?>">
			<div style="position: relative;">
			<span class="self_status" style="display: block;"><font color="#<?=Helper_BSS_Normal::getIniOne('product_sales_status', 'value', $p['sales_status'], 'color')?>"><?=Helper_BSS_Normal::getIniOne('product_sales_status', 'value', $p['sales_status'], 'name')?></font></span>
			<ul class="more_status">
				<?foreach (Q::ini('custom_flag/product_sales_status') as $ss):?>
				<li>
					<a class="change_sales_status_click"><font color="#<?=$ss['color']?>"><?=$ss['name']?></font></a>
					<input type="hidden" value="<?=$p['id']?>_<?=$ss['value']?>" />
				</li>
				<?endforeach;?>
			</ul>
			</div>
		</td>
		<?elseif ($td == '可用库存'):?>
		<td title="可用库存"><?=$p['available_quantity']?></td>
		<?elseif ($td == '实际库存'):?>
		<td title="实际库存"><?=$p['actual_quantity']?></td>
		<?elseif ($td == '待发数量'):?>
		<td title="待发数量"><font <?if ($p['sold_quantity']>$p['actual_quantity']) echo "color='red'"?>><?=$p['sold_quantity']?></font></td>
		<?elseif ($td == '警告库存'):?>
		<td title="警告库存"><?=$p['warning_quantity']?></td>
		<?elseif ($td == '安全库存'):?>
		<td title="安全库存"><?=$p['safe_quantity']?></td>
		<?elseif ($td == '录单数'):?>
		<td title="录单数"><?=$p['purchase_budget_quantity']?></td>
		<?elseif ($td == '采购数'):?>
		<td title="采购数"><?=$p['purchase_quantity']?></td>
		<?elseif ($td == '最近采购价'):?>
		<td title="最近采购价"><?=sprintf('%.2f', $p['last_purchase_price'])?></td>
		<?elseif ($td == '资料成本'):?>
		<td title="资料成本"><?=sprintf('%.2f', $p['purchase_price'])?></td>
		<?elseif ($td == '待入库数'):?>
		<td title="待入库数"><?=$p['purchase_actual_quantity']?></td>
		<?elseif ($td == '周销'):?>
		<td title="周销"><?=$p['weekly_sales']?></td>
		<?elseif ($td == '月销'):?>
		<td title="月销"><?=$p['monthly_sales']?></td>
		<?elseif ($td == '三个月均销'):?>
		<td><?=$p['three_months_avg_sales']?></td>
		<?elseif ($td == '重量g'):?>
		<td title="重量g"><?=sprintf('%d', $p['weight'])?>g</td>
		<?elseif ($td == '创建时间'):?>
		<td title="创建时间"><?=substr($p['create_time'], 0, 10)?></td>
		<?elseif ($td == '最低售价'):?>
		<td title="最低销售价"><?=sprintf('%.2f', $p['sales_floor_price'])?></td>
		<?elseif ($td == '警告状态'):?>
		<td title="警告状态"><font color="#<?=Helper_BSS_Normal::getIniOne('product_warning_status', 'value', $p['warning_status'], 'color')?>"><?=Helper_BSS_Normal::getIniOne('product_warning_status', 'value', $p['warning_status'], 'name')?></font></td>
		<?elseif ($td == '已缺货期'):?>
		<td title="已缺货期"><?=$p['oos_days']?></td>
		<?elseif ($td == '出图时间'):?>
		<td title="出图时间"><?=substr($p['img_add_time'], 0, 10)?></td>
		<?endif;?>
	<?endforeach;?>
</tr>
<?endforeach;?>
</tbody>
</table>
<?=$page?>
<?endif;?>
<div id="customize_display" title="自定义显示">
	<div><h3 style="float: left; margin-right: 120px;">可用列</h3><h3>显示列（拖动排序）</h3></div>
	<ul id="sortable1" title="可用列">
		<li><label><input type="checkbox" value="product_basic_name" <?=(in_array('产品名称', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />产品名称</label></li>
		<li><label><input type="checkbox" value="number" <?=(in_array('产品编号', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />产品编号</label></li>
		<li><label><input type="checkbox" value="notes" <?=(in_array('备注', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />备注</label></li>
		<li><label><input type="checkbox" value="purchase_note" <?=(in_array('采购备注', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />采购备注</label></li>
		<li><label><input type="checkbox" value="purchase_status" <?=(in_array('采购状态', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />采购状态</label></li>
		<li><label><input type="checkbox" value="sales_status" <?=(in_array('销售状态', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />销售状态</label></li>
		<li><label><input type="checkbox" value="available_quantity" <?=(in_array('可用库存', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />可用库存</label></li>
		<li><label><input type="checkbox" value="actual_quantity" <?=(in_array('实际库存', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />实际库存</label></li>
		<li><label><input type="checkbox" value="sold_quantity" <?=(in_array('待发数量', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />待发数量</label></li>
		<li><label><input type="checkbox" value="warning_quantity" <?=(in_array('警告库存', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />警告库存</label></li>
		<li><label><input type="checkbox" value="safe_quantity" <?=(in_array('安全库存', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />安全库存</label></li>
		<li><label><input type="checkbox" value="purchase_budget_quantity" <?=(in_array('录单数', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />录单数</label></li>
		<li><label><input type="checkbox" value="purchase_quantity" <?=(in_array('采购数', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />采购数</label></li>
		<li><label><input type="checkbox" value="last_purchase_price" <?=(in_array('最近采购价', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />最近采购价</label></li>
		<li><label><input type="checkbox" value="purchase_price" <?=(in_array('资料成本', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />资料成本</label></li>
		<li><label><input type="checkbox" value="purchase_actual_quantity" <?=(in_array('待入库数', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />待入库数</label></li>
		<li><label><input type="checkbox" value="warehouse_name" <?=(in_array('所在仓库', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />所在仓库</label></li>
		<li><label><input type="checkbox" value="weekly_sales" <?=(in_array('周销', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />周销</label></li>
		<li><label><input type="checkbox" value="monthly_sales" <?=(in_array('月销', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />月销</label></li>
		<li><label><input type="checkbox" value="three_months_avg_sales" <?=(in_array('三个月均销', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />三个月均销</label></li>
		<li><label><input type="checkbox" value="weight" <?=(in_array('重量g', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />重量g</label></li>
		<li><label><input type="checkbox" value="create_time" <?=(in_array('创建时间', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />创建时间</label></li>
		<li><label><input type="checkbox" value="sales_floor_price" <?=(in_array('最低售价', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />最低售价</label></li>
		<li><label><input type="checkbox" value="warning_status" <?=(in_array('警告状态', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />警告状态</label></li>
		<li><label><input type="checkbox" value="oos_days" <?=(in_array('已缺货期', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?>/>已缺货期</label></li>
		<li><label><input type="checkbox" value="img_add_time" <?=(in_array('出图时间', $_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'])) ? 'checked="checked"' : ''?> />出图时间</label></li>
	</ul>
	<form action="<?=url('DataCenter::Sales/CustomizeDispalyStockAnalysis')?>" method="post">
	<ul id="sortable2" class="dropfalse" title="显示列">
		<?foreach ($_SESSION[Q::ini('custom_userdata_session_key')]['customize_sales_stock_analysis'] as $k => $s):?>
		<li class="ui-state-highlight"><?=$s?><input type="hidden" name="fieldname[<?=$k?>]" value="<?=$s?>" /></li>
		<?endforeach;?>
	</ul>
	<input type="submit" class="button" value="确定显示" />
	</form>
</div>
<?php $this->_endblock();?>